package com.android.settings.audio.peq.peq.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.LinearLayout;

/**
 * Created by We on 2023/4/3
 */
public class GroupLinearLayout extends LinearLayout {
    private Paint paint = new Paint();
    private static final float LINE_WIDTH = 0.5f;

    public GroupLinearLayout(Context context) {
        this(context, null);
    }

    public GroupLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void draw(Canvas canvas) {
        paint.setColor(bgColor);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawRoundRect(LINE_WIDTH / 2f, LINE_WIDTH, getWidth() - LINE_WIDTH, getHeight() - LINE_WIDTH, 8, 8, paint);
        super.draw(canvas);
        paint.setColor(lineColor);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(LINE_WIDTH);
        canvas.drawRoundRect(LINE_WIDTH / 2f, LINE_WIDTH, getWidth() - LINE_WIDTH, getHeight() - LINE_WIDTH, 8, 8, paint);
    }

    private int lineColor;
    private int bgColor;

    public void setLineColor(int lineColor) {
        this.lineColor = lineColor;
        invalidate();
    }

    public void setBgColor(int bgColor) {
        this.bgColor = bgColor;
        invalidate();
    }
}
